/*
 *  $Id: ButtonNHSprite.cs 636 2009-07-13 12:54:09Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2009 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

using AgateLib.Geometry;

namespace Ragima.UI {
    /// <summary>
    /// Кнопка, два состояния которой являются спрайтами, pressed равно hovered, а disabled рисуется как normal с 30% альфа.
    /// </summary>
    public class ButtonNHSprite: Button {
        private Sprite _sprite;

        public ButtonNHSprite(Sprite sprite, Point point, SimpleEvent action): base(new Rectangle(point, sprite.Descriptor.Size), action) {
            _sprite = sprite;
        }

        public override void DrawButtonNormal() {
            _sprite.Draw(0, Rect.Location);
        }

        public override void DrawButtonHovered() {
            _sprite.Draw(1, Rect.Location);
        }

        public override void DrawButtonPressed() {
            _sprite.Draw(1, Rect.Location);
        }

        public override void DrawButtonDisabled() {
            double alpha = _sprite.Surface.Alpha;
            _sprite.Surface.Alpha = 0.3;
            _sprite.Draw(0, Rect.Location);
            _sprite.Surface.Alpha = alpha;
        }
    }
}
